package ba.examples.hibernate;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;

import org.apache.log4j.Logger;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.cfg.Configuration;
import org.hibernate.tool.hbm2ddl.SchemaExport;

public class SchemaExporter {
	
	private static Logger log = Logger.getLogger(SchemaExport.class);
	
	
	public static void main(String[] args) throws FileNotFoundException, IOException {
		
		File fileHibernateConfig = new File("src/main/resources/hibernate.cfg.xml");
		
		Configuration cfg = new AnnotationConfiguration().configure(fileHibernateConfig);
		
		SchemaExport exporter = new SchemaExport(cfg);
		exporter.setFormat(true);
		exporter.setDelimiter(";");
		exporter.setOutputFile("resources/sql/sqlschema.sql");
		
		log.info("Schema export - start");
		
		exporter.create(false, false);
		
		log.info("Schema export - stop");
		
	}

}
